package cn.tedu.submarine;
import javax.swing.ImageIcon;

/*
战舰类
 */
public class Battleship extends SeaObject {
    /**数据私有，行为公开**/
    private int life;//命

   public Battleship(){//构造方法第一次赋值初始化
        super(66,26,270,124,20);
        life = 5;
    }

    /*重写Move移动*/
    public void move() {
        //暂时搁置
    }
    public ImageIcon getImage(){
        return Images.battleship;
    }

    /**生成深水炸弹对象*/
    public Bomb shootBomb(){
        return new Bomb(this.x,this.y+10);
    }
    public Bomb shootBomb2(){
        return new Bomb(this.x+width,this.y+10);
    }
    public Bomb shootBomb3(){
        return new Bomb(this.x+width/2,this.y+10);
    }

    public void moveLeft(){
        x -= speed;
    }
    public void moveRight(){
        x += speed;
    }
    public void moveUp(){
        y -= speed;
    }
    public void moveDown(){
        y += speed;
    }

    /**数据私有，行为公开**/
    public void  addLife(int num){
        life += num;
    }

    /**获取命数**/
    public int getLife(){
        return life;//返回命数
    }

    /**战舰减命**/
    public  void subtractLife(){
        life--;
    }

    public boolean isOutofBounds(){
        return x <= 0 || x>= World.WIDTH - width;
    }
    public boolean isLeftOutofBound(){
        return x <= 0;
    }
    public boolean isRightOutofBound(){
        return x>= World.WIDTH - width;
    }
}


